import { AddwarehouseOrderShipmentCostApi } from "@/api/waybillManagement/warehouseShipment";
import FormHook from "@/hook/formHook";
import { message } from "ant-design-vue";

export default function OperationHook(state: Base.GeneraDataType) {
  const { formDataRef, formState, emit, passData } = state;
  const { resetFields } = FormHook({ formState });
  // const { getLabelByDict } = CommonHook();
  const onFinish = () => {
    const params = {
      ...formState,
      waybillNum: passData.value.warehouseBillNum
    };
    return AddwarehouseOrderShipmentCostApi(params).then(() => {
      message.success("操作成功");
      emit("submit");
    });
  };
  const cancelHandle = () => {
    resetFields();
    formDataRef.value.clearValidate();
    emit("update:visible", false);
  };

  return {
    onFinish,
    cancelHandle,
    resetFields
  };
}
